package com.leizi.igym.utils;

import com.leizi.igym.constant.Salt;
import org.springframework.util.DigestUtils;

/**
 * @Author: leizi0110
 * @CreateTime: 2024-04-02  21:19
 * @Description:
 */

public class PwdEncryptUtils {

    /**
     *  写死的盐加密方法
     *
     * @param: [originPwd]
     * @return: java.lang.String
     **/
    public static String encryptPwd(String originPwd){
        if (originPwd.isBlank()){
            return "";
        }
        return DigestUtils.md5DigestAsHex((Salt.ADMIN_PWD_SALT + originPwd).getBytes());
    }

    /**
     *  若将盐存在数据库中，则进行了一下方法的重载
     *
     * @param: [salt, originPwd]
     * @return: java.lang.String
     **/
    public static String encryptPwd(String salt,String originPwd){
        if (originPwd.isBlank()){
            return "";
        }
       return DigestUtils.md5DigestAsHex((salt + originPwd).getBytes());
    }
}
